﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JQuery
{
    [ToolboxData("<{0}:CSSRegistration runat=server></{0}:CSSRegistration>")]
    public class CSSRegistration : Control
    {
        #region constructors
        public CSSRegistration()
        {
            EnableViewState = false;
        }
        #endregion
        /// <summary>
        /// Get a reference to the Resource Manager
        /// </summary>
        private static Resource Manager { get { return Module.Manager; } }

        [Bindable(true)]
        [Category("Behavior")]
        [DefaultValue("")]
        [Localizable(false)]
        public string Href { get; set; }
        /// <summary>
        /// Register a css file with the resource manager
        /// </summary>
        /// <param name="id">unique key identifier</param>
        /// <param name="uri">server relative url</param>
        public static void Registration(string id, string uri)
        {
            Page oPage = HttpContext.Current.Handler as Page;

            oPage.RegisterResourceInclude(id, uri, Resource.ContentTypes.css);
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ///register the resource
            Registration(Href, Page.ResolveUrl(Href));
        }

        
    }
}
